package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Return implements IOperation{
    public void work(BookList bookList) {
        System.out.println("==归还图书==");

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入图书名字:>");
        String name = scanner.nextLine();
        int currentUsedSize = bookList.getUsedSize();
        for (int i = 0; i < currentUsedSize; i++) {
            Book book = bookList.getPosBooks(i);
            if(book.getName().equals(name)) {//字符串的比较，用equals
                bookList.getPosBooks(i).setBorrowed(false);
                System.out.println("归还成功！");
                return;
            }
        }
        System.out.println("没有你要归还的书！");
    }
}
